import {request} from "../../request/index.js"
const app = getApp();

Page({
  /**
   * 页面的初始数据
   */
  data: {
    maxNumber:200,//可输入最大字数
    number: 0,//已输入字数
    id: '',
    input: ''
  },

  inputText: function (e) { //监听输入，实时改变已输入字数
    let value = e.detail.value;//获取textarea的内容，
    let len = value.length;//获取textarea的内容长度
    this.setData({
      'number': len
    })
  },
  onLoad(options) {
    this.setData({
      id: options.id
    })
  },
  inputText(e) {
    var input = ''
    this.setData({
      input: e.detail.value
    })
  },
  issue() {
    request({
      url: '/client/commit/comment',
      method: 'POST',
      data: {
        planId: this.data.id,
        message: this.data.input,
        userId: app.userId
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      }
    })
    .then(res => {
      wx.navigateBack({
        delta: 1,
      })
    })
  }
  
})